package com.wjggy.core.action.user;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wjggy.core.action.view.UserView;
import com.wjggy.core.common.springview.ViewUtil;
import com.wjggy.core.entities.User;
import com.wjggy.core.service.user.LoginService;

/**
 * <p>Description:  用户登录管理</p>
 * <p>Copyright:Copyright (c) 2012  </p>
 * <p>Company:wjggy  </p>
 * @author xiaofan.yu  
 * @date   2012-1-8 下午10:53:25    
 * @project  wjggy
 * @version  1.0.0
 * @see   
 *  @since 1.6
 */
@Controller
@RequestMapping("/login")
public class LoginAction {
	@Resource(name="loginService")
	LoginService loginService;
	/**
	 * 
	 *  @describe 管理员登录
	 *  @param request
	 *  @param response
	 *  @param admin
	 *  @return
	 */
	@RequestMapping("/adminCheck")
	public ModelAndView loginAdmin(HttpServletRequest request,
			HttpServletResponse response, User admin) {
		int status=loginService.loginAdmin(response, admin, null);
//		System.out.println(status);
		if(status==1){
			return ViewUtil.findView("admin/index");
		}else{
			return ViewUtil.findRedirectView(UserView.ADMIN_LOGIN_URL);
		}
	}
	@RequestMapping("/adminLogin")
	public ModelAndView login(HttpServletRequest request, HttpServletResponse response) {
		return  ViewUtil.findView(UserView.ADMIN_LOGIN_PAGE);
	}
	public LoginService getLoginService() {
		return loginService;
	}
	public void setLoginService(LoginService loginService) {
		this.loginService = loginService;
	}
	
}
